package com.mudrov.anagram.helpers;

import java.util.HashSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class StringParser implements WordParser {

    @Override
    public String[] parseSomeString(String stringToParse) {
        String[] arrayOfAllWords = stringToParse.toUpperCase().split("[ ;:!?.,\"()]");
        Pattern pattern = Pattern.compile("[A-ZА-Я]+");
        Matcher matcher = null;
        HashSet<String> hashOfWord = new HashSet<String>();
        for (String i : arrayOfAllWords) {
            matcher = pattern.matcher(i);
            if (matcher.matches())
                hashOfWord.add(i);
        }
        return hashOfWord.toArray(new String[0]);
    }

}
